<template>
  <div>
    <px-select
      v-model="data.autoMeterReadingPoint"
      placeholder="请选择自动抄表点"
      clearable
      filterable
      :disabled="disabled"
      style="width: 100%"
      @focus="focusAutoMeterReadingPoint(eqpId)"
    >
      <px-option v-for="item in pointList" :key="item.measureCode" :label="item.measureName" :value="item.measureCode" />
    </px-select>
  </div>
</template>

<script lang="ts" setup>
import { computed } from "vue";
const props = defineProps(["meterReadingPointList", "disabled", "eqpId"]);
const data: any = defineModel();
const emits = defineEmits(["focusAutoMeterReadingPoint"]);
const focusAutoMeterReadingPoint = id => {
  emits("focusAutoMeterReadingPoint", id);
};
const pointList = computed(() => {
  const { autoMeterReadingPointName, autoMeterReadingPoint } = data.value;
  if (props.meterReadingPointList?.length) {
    return props.meterReadingPointList;
  } else if (autoMeterReadingPointName && autoMeterReadingPoint) {
    return [{ id: 1, measureName: data.value.autoMeterReadingPointName, measureCode: data.value.autoMeterReadingPoint }];
  } else {
    return [];
  }
});
</script>
<style lang="scss" scoped></style>
